<template>
	<div class="card-box">
		<div class="card-box-title" :class="dis" :style="{paddingLeft: pleft}" v-if="title">
			<u-icon :size="iconSize" :name="icon" v-if="icon"></u-icon>
			{{title}}
		</div>
		<slot></slot>
	</div>
</template>

<script>
	export default {
		name: "card-box",
		props: {
			title: {},
			showLine: {},
			// 左侧图标src
			icon: {
				type: String,
				default: ''
			},
			// 左边图标的大小
			iconSize: {
				type: Number,
				default: 17
			},
		},
		computed: {
			dis() {
				return this.showLine ?? true ? 'block' : 'none';
			},
			pleft() {
				return this.showLine ?? true ? '10px' : '0';
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card-box {
		border-radius: 8px;
		background: rgba(255, 255, 255, .98);
		padding: 20px 15px;
		margin: 12px 0;

		&-title {
			padding-left: 10px;
			color: #333;
			font-size: 14px;
			line-height: 1;
			position: relative;
			display: flex;
			align-items: center;

			&.dis {
				&:before {
					display: none;
				}
			}

			&:before {
				display: block;
				content: "";
				position: absolute;
				top: 10%;
				bottom: 0;
				width: 4px;
				height: 90%;
				margin: auto;
				background-color: #2757F5;
				border-radius: 9999px;
				transform: translateX(-10px);
			}
		}

		.u-cell__left-icon-wrap {
			margin-right: 5px;
			font-size: 16px;
		}

		.u-cell__right-icon-wrap {
			margin-left: 5px;
			color: #969799;
			font-size: 14px;
			align-items: center;
			height: 24px;
		}
	}
</style>